package com.chang.service.impl;

import com.chang.entity.Admin;
import com.chang.entity.scale_personality;
import com.chang.mapper.AdminMapper;
import com.chang.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service/*加入Spring容器*/
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public void add(Admin newAdmin) {
        adminMapper.add(newAdmin);
    }

    /*登录检测，用于管理员*/
    @Override
    public Admin checkAdmin(String username, String password) {
        return adminMapper.checkAdmin(username,password);
    }
    /*登录检测，用于用户*/
    @Override
    public Admin checkUser(String username, String password) {
        return adminMapper.checkUser(username,password);
    }
    /*id检索*/
    @Override
    public Admin checkAdminById(Integer id) {
        return adminMapper.checkAdminById(id);
    }
    @Override
    public Admin checkUserById(Integer id) {
        return adminMapper.checkUserById(id);
    }
    /*name的检索*/
    @Override
    public Admin checkAdminByName(String username) {
        return adminMapper.checkAdminByName(username);
    }
    @Override
    public Admin checkUserByName(String username) {
        return adminMapper.checkUserByName(username);
    }

    /*查询所有管理员*/
    @Override
    public List<Admin> findAllAdmin() {
        return adminMapper.findAllAdmin();
    }
    /*查询所有用户*/
    @Override
    public List<Admin> findAllUser() {
        return adminMapper.findAllUser();
    }

    @Override
    public List<Admin> Count() {
        return adminMapper.Count();
    }

    /*注册，插入管理员*/
    @Override
    public int insertAdmin(String username, String password, String phone) {
        return adminMapper.insertAdmin(username,password,phone);
    }
    /*注册，插入用户*/
    @Override
    public int insertUser(String username, String password, String phone) {
        return adminMapper.insertUser(username,password,phone);
    }

    /*更新管理员信息*/
    @Override
    public int updateAdmin(Admin admin) {
        return adminMapper.updateAdmin(admin);
    }
    /*更新用户信息*/
    @Override
    public int updateUser(Admin admin) {
        return adminMapper.updateUser(admin);
    }

    /*删除管理员*/
    @Override
    public boolean deleteAdmin(int id) {
        return adminMapper.deleteAdmin(id);
    }
    /*删除用户*/
    @Override
    public boolean deleteUser(int id) {
        return adminMapper.deleteUser(id);
    }
    /*上传心理量表*/
    @Override
    public void addScaleProblem(scale_personality scale_personality) {
        adminMapper.addScaleProblem(scale_personality);
    }

    /*miao*/
    @Override
    public List<Admin> AllInfo() {
        return adminMapper.AllInfo();
    }
}
